
#ifndef __THREAD_POOL_H
#define __THREAD_POOL_H

class ThreadPool
{
	std::vector<WorkThread*> threads;
	const Settings& settings;

public:

	ThreadPool(const Settings& _settings, WorkLoad *workLoad)
		:	settings(_settings) {

		Initialise(workLoad);
	}


	virtual ~ThreadPool() {

		CleanUp();
	}

private:

	void Initialise(WorkLoad *workLoad) {

		int tc = settings.GetThreadCount();

		for(int i=0; i<tc; i++)
			threads.push_back( new WorkThread( settings, workLoad ) );
	}

	void CleanUp() {

		for(std::vector<WorkThread*>::iterator it = threads.begin();
			it != threads.end();
			it++)
				delete *it;

		threads.resize(0);
	}

};

#endif /*** __THREAD_POOL_H ***/

